package com.nodusk.result;

import cn.hutool.core.util.StrUtil;


import java.util.List;
import java.util.Map;


public class Parameter<T> {
    /**
     * 开始位置
     */
    private long startIndex;
    /**
     * 结束位置
     */
    private long endIndex;
    /**
     * 每页数
     */
    private long pageSize;
    /**
     * 排序
     */
    private String orderBy;
    /**
     * 是否倒序 true/false
     */
    private String desc;
    /**
     * 实体参数
     */
    private T data;
    /**
     * 下拉框多选条件 格式 {字段:['数据','']}
     */
    private Map<String, List<String>> multipleChoiceCondition;
    /**
     * 范围条件 格式 {字段:{startTime:"开始值",endTime:"结束值"}}
     */
    private Map<String, Map<String, String>> universalTime;
    /**
     * 开始时间
     */
    private String startTime;
    /**
     * 条件排序字段
     */
    private String singleColumnSort;
    /**
     * 条件排序值
     */
    private String singleColumnSortValue;
    /**
     * 结束时间
     */
    private String endTime;
    /**
     * 等于
     */
    private List<FieldCondition> fieldConditionList;

    /**
     *
     */
    private String withinAFewDays;
    /**
     *
     */
    private String daysNumber;
    /**
     *
     */
    private String firstLetter;
    /**
     *
     */
    private String executingState;
    /**
     * 不为空筛选字段
     */
    private String[] notNullAttributes;
    /**
     * 为空筛选字段
     */
    private String[] isNullAttributes;
    /**
     * 全局查询
     */
    private String globalSearch;
    /**
     *
     */
    private String isLimit;
    /**
     * 数值金额全局查询
     */
    private Double amountSearch;
    /**
     * 多条件全局查询
     */
    private List<String> globalSearchs;
    /**
     * 全局模糊查询 格式 {字段:'条件'}
     */
    private Map<String, String> globalSearchREGEXP;
    /**
     * 模糊查询 格式 {字段:'条件'}
     */
    private Map<String, String> likeNameSearch;
    /**
     * 自定义条件
     */
    private String customConditionsSql;
    private String groupBy;


    public List<String> getGlobalSearchs() {
        return globalSearchs;
    }

    public void setGlobalSearchs(List<String> globalSearchs) {


        if (globalSearchs != null && globalSearchs.size() > 0) {
            this.globalSearchs = globalSearchs;
            StringBuffer stringBuffer = new StringBuffer("(");
            for (String s :
                    globalSearchs) {
                if (s != null && !s.equals("")) {
                    stringBuffer.append("'" + s + "',");
                }

            }
            if (stringBuffer != null && stringBuffer.length() > 2) {
                String s = StrUtil.removeSuffix(stringBuffer.toString(), ",") + ")";
                this.globalSearch = s;
            }


        }

    }

    public long getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(long startIndex) {
        this.startIndex = startIndex;
    }

    public long getEndIndex() {
        return endIndex;
    }

    public void setEndIndex(long endIndex) {
        this.endIndex = endIndex;
    }

    public long getPageSize() {
        return pageSize;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Map<String, List<String>> getMultipleChoiceCondition() {
        return multipleChoiceCondition;
    }

    public void setMultipleChoiceCondition(Map<String, List<String>> multipleChoiceCondition) {
        this.multipleChoiceCondition = multipleChoiceCondition;
    }

    public Map<String, Map<String, String>> getUniversalTime() {
        return universalTime;
    }

    public void setUniversalTime(Map<String, Map<String, String>> universalTime) {
        this.universalTime = universalTime;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getSingleColumnSort() {
        return singleColumnSort;
    }

    public void setSingleColumnSort(String singleColumnSort) {
        this.singleColumnSort = singleColumnSort;
    }

    public String getSingleColumnSortValue() {
        return singleColumnSortValue;
    }

    public void setSingleColumnSortValue(String singleColumnSortValue) {
        this.singleColumnSortValue = singleColumnSortValue;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public List<FieldCondition> getFieldConditionList() {
        return fieldConditionList;
    }

    public void setFieldConditionList(List<FieldCondition> fieldConditionList) {
        this.fieldConditionList = fieldConditionList;
    }

    public String getWithinAFewDays() {
        return withinAFewDays;
    }

    public void setWithinAFewDays(String withinAFewDays) {
        this.withinAFewDays = withinAFewDays;
    }

    public String getDaysNumber() {
        return daysNumber;
    }

    public void setDaysNumber(String daysNumber) {
        this.daysNumber = daysNumber;
    }

    public String getFirstLetter() {
        return firstLetter;
    }

    public void setFirstLetter(String firstLetter) {
        this.firstLetter = firstLetter;
    }

    public String getExecutingState() {
        return executingState;
    }

    public void setExecutingState(String executingState) {
        this.executingState = executingState;
    }

    public String[] getNotNullAttributes() {
        return notNullAttributes;
    }

    public void setNotNullAttributes(String[] notNullAttributes) {
        this.notNullAttributes = notNullAttributes;
    }

    public String[] getIsNullAttributes() {
        return isNullAttributes;
    }

    public void setIsNullAttributes(String[] isNullAttributes) {
        this.isNullAttributes = isNullAttributes;
    }

    public String getGlobalSearch() {
        return globalSearch;
    }

    public void setGlobalSearch(String globalSearch) {
        this.globalSearch = globalSearch;
    }

    public String getIsLimit() {
        return isLimit;
    }

    public void setIsLimit(String isLimit) {
        this.isLimit = isLimit;
    }

    public Double getAmountSearch() {
        return amountSearch;
    }

    public void setAmountSearch(Double amountSearch) {
        this.amountSearch = amountSearch;
    }

    public Map<String, String> getGlobalSearchREGEXP() {
        return globalSearchREGEXP;
    }

    public void setGlobalSearchREGEXP(Map<String, String> globalSearchREGEXP) {
        this.globalSearchREGEXP = globalSearchREGEXP;
    }

    public Map<String, String> getLikeNameSearch() {
        return likeNameSearch;
    }

    public void setLikeNameSearch(Map<String, String> likeNameSearch) {
        this.likeNameSearch = likeNameSearch;
    }

    public String getCustomConditionsSql() {
        return customConditionsSql;
    }

    public void setCustomConditionsSql(String customConditionsSql) {
        this.customConditionsSql = customConditionsSql;
    }

    public String getGroupBy() {
        return groupBy;
    }

    public void setGroupBy(String groupBy) {
        this.groupBy = groupBy;
    }

    public Parameter() {

    }


    public Parameter(T data, Integer pageSize) {
        this.data = data;
        this.pageSize = pageSize;
    }


    public Parameter(T data) {
        this.data = data;
    }


}
